package cn.edu.scau.cmi.zhaoguangfeng.hibernate.server;

import java.util.List;

import cn.edu.scau.cmi.zhaoguangfeng.domain.Student;
import cn.edu.scau.cmi.zhaoguangfeng.domain.Teacher;
import cn.edu.scau.cmi.zhaoguangfeng.hibernate.dao.BaseHibernateDAO;
import cn.edu.scau.cmi.zhaoguangfeng.hibernate.dao.StudentDAO;
import cn.edu.scau.cmi.zhaoguangfeng.hibernate.dao.TeacherDAO;

public class HibernateServerImp implements IHibernateServer {

	private BaseHibernateDAO<Student> studentDao = new StudentDAO<Student>() ;
	private BaseHibernateDAO<Teacher> teacherDao = new TeacherDAO<Teacher>() ;
	
	public void addStudent(Student s) {
		studentDao.save(s);
	}
	
	public void addTeacher(Teacher t) {
		teacherDao.save(t);
	}
	
	public Student findStudentByID(long id) {
		return studentDao.findById(id);
	}
	public Teacher findTeacherByID(long id) {
		return teacherDao.findById(id);
		
	}
	
	public List<Student> findStudentByName(String name) {
		return studentDao.findByName(name);
	}
	
	public List<Teacher> findTeacherByName(String name) {
		return teacherDao.findByName(name);
		
	}
	
	public List<Student> findAllStudents(){
		return studentDao.findAll();
	}
	public List<Teacher> findAllTeachers(){
		return teacherDao.findAll();
	}
	
	public void deleteStudent(Student s) {
		studentDao.delete(s);
	}
	
	public void deleteTeacher(Teacher t) {
		teacherDao.delete(t);
	}
}
